//
//  XiaoJianPanExerciseViewController.swift
//  ZHM
//
//  Created by zzddongge on 16/9/10.
//  Copyright © 2016年 zzd. All rights reserved.
//

import UIKit

class XiaoJianPanExerciseViewController: UIViewController,UITextFieldDelegate,UITextViewDelegate,SheZhiLabelYangShiViewControllerDelegate,ZSDSetPasswordViewDelegate{

    //获取模拟器或者真机的宽度和高度
    let screenWidth = UIScreen.main.bounds.width
    let screenHeight = UIScreen.main.bounds.height
    
    //定义一个变量,用于存储模式类别
    var moShiLeiBie:String?
    
    //设置按钮
    var sheZhiBtn:UIButton?
    
    //定义scrollView对象
    var scrollView:UIScrollView?
    
    //定义三个ImageView
    var zanTingImageView:UIImageView?
    var chaKanJieGuoImageView:UIImageView?
    var jieShuImageView:UIImageView?
    
    //定义两个View对象
    var firstFenGeXianView:UIView?
    var secondFenGeXianView:UIView?
    
    //定义三个按钮
    var zanTingBtn:UIButton?
    var chaKanJieGuoBtn:UIButton?
    var jieShuBtn:UIButton?
    
    //定义一条横线UIView
    var hengXianView:UIView?
    
    //创建8个UILabel对象
    var zhengQueShuLabel:UILabel?
    var zhengQueShuLabelValue:UILabel?
    
    var zhengQueLvLabel:UILabel?
    var zhengQueLvLabelValue:UILabel?
    
    var shiJianLabel:UILabel?
    var shiJianLabelValue:UILabel?
    
    var suDuLabel:UILabel?
    var suDuLabelValue:UILabel?
    
    //定义三个UIView,用于分割成四个模块
    var leftView:UIView?
    var middleView:UIView?
    var rightView:UIView?
    
    //定义一条横线UIView
    var secondHengXianView:UIView?
    
    //定义6个UIlabel对象,用于存储随机生成的6个数字
    var firstLabel:UILabel?
    var secondLabel:UILabel?
    var thirdLabel:UILabel?
    var fourthLabel:UILabel?
    var fifthLabel:UILabel?
    var sixthLabel:UILabel?
    
    //定义6个UITextField对象,用于存储用户输入的值
    var firstTextFieldValue:UITextField?
    var secondTextFieldValue:UITextField?
    var thirdTextFieldValue:UITextField?
    var fourthTextFieldValue:UITextField?
    var fifthTextFieldValue:UITextField?
    var sixthTextFieldValue:UITextField?
    
    //定义一个textView,用于初始化一个键盘
    var jianPanTextView:UITextView?
    
    //定义一个变量,用于存储随机生成的数字
    var randomNumber:Int?
    
    //定义一个变量,用于存储正确数
    var zhengQueShu:Int = 0
    
    //定义一个变量,用于存储正确率
    var zhengQueLv:Double = 0.0
    
    //定义一个变量,用于存储小键盘训练速度
    var xiaoJianPanLianXiSuDu = 0
    
    //定义一个变量,用于存储所有整数
    var suoYouZhengShu:Int = 0
    
    //定义一个变量,用于存储传递过来的分钟值
    var fenZhongZhi:String?
    
    //定义一个定时器
    var timer:Timer!
    
    //定义一个变量:保存计时器时间的值
    var timerValue:Int = 0
    
    //定义一个变量,用于保存传递过来的indexPath.row
    var indexPathDianRow:Int = 0
    
    var indexPathRow:Int = 0
    
    
    //定义一个变量,用于存储设置lable边框形状的indexPathDianRow
    var bianKuangXingZhuangIndexPathDianRow:Int = 0
    
    //定义一个类似支付宝的输入view
    var inputViews:ZSDSetPasswordView?

    //定义一个完成按钮
    var finishBtn:UIButton?
    
    //定义一个变量,用于保存用户中间点击完成时,输入的位置
    var dianJiWanChengWeiZhi:Int = 0
    
    //定义一个全局变量,用于保存点击完成按钮时的数字串
    var dianJiWanChengShuZiChuan:String?
    
    override func viewDidLoad() {
        
        fengZhuangViewDidLoad()
        
        // Do any additional setup after loading the view.
    }
    
    
    //2.监听键盘出现的事件
    override func viewWillAppear(_ animated: Bool) {
        NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardDidShow), name:NSNotification.Name.UIKeyboardDidShow, object: nil)
        
//        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(handleKeyboardWillHide), name:UIKeyboardWillHideNotification, object: nil)
        
        NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardWillShow), name:NSNotification.Name.UIKeyboardWillShow, object: nil)
    }
    
    /*
        作者:张振东
        时间:2016-9-22
        功能:监听键盘消失的事件
     */
    override func viewWillDisappear(_ animated: Bool) {
         NotificationCenter.default.removeObserver(self)
    }

    
    func handleKeyboardWillShow(_ notification:Notification){
        let info:NSDictionary = notification.userInfo! as NSDictionary
        let cgRectValue = (info.object(forKey: "UIKeyboardBoundsUserInfoKey"))!
        print(cgRectValue)
        let keyboardHeight = ((cgRectValue as Any) as AnyObject).cgRectValue.size.height
        let keyboardWidth = ((cgRectValue as Any) as AnyObject).cgRectValue.size.width
        print(keyboardHeight)
        print(keyboardWidth)
        // create custom button
        if finishBtn != nil{
            //自定义初始化完成按钮
            finishBtn = UIButton(frame:CGRect(x: 2*keyboardWidth/3+35,y: screenHeight-(keyboardHeight/3)+30, width: keyboardWidth/5+10, height: keyboardHeight/5))
            
            finishBtn!.adjustsImageWhenHighlighted = false
            finishBtn?.setTitle("完成", for: UIControlState())
            finishBtn?.setTitleColor(UIColor.black, for: UIControlState())
            finishBtn?.layer.cornerRadius = 10
            finishBtn?.backgroundColor = UIColor(red: 161/255, green: 161/255, blue: 161/255, alpha: 1)
            finishBtn?.setImage(UIImage(named: "numPadDoneUp.png"), for: UIControlState())
            finishBtn?.setImage(UIImage(named: "numPadDoneDown.png"), for: .highlighted)
            finishBtn?.addTarget(self, action: #selector(finishAction), for: .touchUpInside)
            // locate keyboard view
            let tempWindow:UIWindow = UIApplication.shared.windows[2]
            print(tempWindow)
            
            tempWindow.addSubview(self.finishBtn!)
        }else{
            //自定义初始化完成按钮
            finishBtn = UIButton(frame:CGRect(x: 2*keyboardWidth/3+35,y: screenHeight-(keyboardHeight/3)+30, width: keyboardWidth/5+10, height: keyboardHeight/5))
            
            finishBtn!.adjustsImageWhenHighlighted = false
            finishBtn?.setTitle("完成", for: UIControlState())
            finishBtn?.setTitleColor(UIColor.black, for: UIControlState())
            finishBtn?.layer.cornerRadius = 10
            finishBtn?.backgroundColor = UIColor(red: 161/255, green: 161/255, blue: 161/255, alpha: 1)
            finishBtn?.setImage(UIImage(named: "numPadDoneUp.png"), for: UIControlState())
            finishBtn?.setImage(UIImage(named: "numPadDoneDown.png"), for: .highlighted)
            finishBtn?.addTarget(self, action: #selector(finishAction), for: .touchUpInside)
            // locate keyboard view
            let tempWindow:UIWindow = UIApplication.shared.windows[2]
            print(tempWindow)
            
            tempWindow.addSubview(self.finishBtn!)

        }

    }
    
    /*
        作者:张振东
        时间:2016-9-22
        功能:处理键盘已经加载的事件
     */
    func handleKeyboardDidShow(_ notification:Notification){
        let info:NSDictionary = notification.userInfo! as NSDictionary
        let cgRectValue = (info.object(forKey: "UIKeyboardBoundsUserInfoKey"))!
        print(cgRectValue)
        let keyboardHeight = ((cgRectValue as Any) as AnyObject).cgRectValue.size.height
        let keyboardWidth = ((cgRectValue as Any) as AnyObject).cgRectValue.size.width
        print(keyboardHeight)
        print(keyboardWidth)
        // create custom button
        if finishBtn == nil{
            //自定义初始化完成按钮
            finishBtn = UIButton(frame:CGRect(x: 2*keyboardWidth/3+35,y: screenHeight-(keyboardHeight/4)+30, width: keyboardWidth/3+10, height: keyboardHeight/4))
            
            finishBtn!.adjustsImageWhenHighlighted = false
            finishBtn?.setTitle("完成", for: UIControlState())
            finishBtn?.setTitleColor(UIColor.black, for: UIControlState())
            finishBtn?.backgroundColor = UIColor(red: 161/255, green: 161/255, blue: 161/255, alpha: 1)
            finishBtn?.setImage(UIImage(named: "numPadDoneUp.png"), for: UIControlState())
            finishBtn?.setImage(UIImage(named: "numPadDoneDown.png"), for: .highlighted)
            finishBtn?.addTarget(self, action: #selector(finishAction), for: .touchUpInside)
            // locate keyboard view
            let tempWindow:UIWindow = UIApplication.shared.windows[2]
            print(tempWindow)
            
            tempWindow.addSubview(self.finishBtn!)
        }
        
    }
    
    /*
        作者:张振东
        时间:2016-9-22
        功能:点击完成按钮触发的事件
     
     */
    func finishAction(){
        if firstTextFieldValue?.text == "" || firstTextFieldValue?.text == nil || secondTextFieldValue?.text == "" || secondTextFieldValue?.text == nil || thirdTextFieldValue?.text == "" || thirdTextFieldValue?.text == nil || fourthTextFieldValue?.text == "" || fourthTextFieldValue?.text == nil || fifthTextFieldValue?.text == "" || fifthTextFieldValue == nil || sixthTextFieldValue?.text == "" || sixthTextFieldValue?.text == nil{
            finishBtn?.isUserInteractionEnabled = false
            dianJiWanChengWeiZhi = (dianJiWanChengShuZiChuan?.characters.count)!
            print(dianJiWanChengWeiZhi)
            
        }else{
            finishBtn?.isUserInteractionEnabled = true
            //开始下一轮,需要将所有的数字置空
            firstTextFieldValue?.text = ""
            secondTextFieldValue?.text = ""
            thirdTextFieldValue?.text = ""
            fourthTextFieldValue?.text = ""
            fifthTextFieldValue?.text = ""
            sixthTextFieldValue?.text = ""
            
            //开始下一轮,需要将所有的前面的带颜色的textField的颜色置为白色
            firstTextFieldValue?.backgroundColor = UIColor.white
            secondTextFieldValue?.backgroundColor = UIColor.white
            thirdTextFieldValue?.backgroundColor = UIColor.white
            fourthTextFieldValue?.backgroundColor = UIColor.white
            fifthTextFieldValue?.backgroundColor = UIColor.white
            sixthTextFieldValue?.backgroundColor = UIColor.white
            
            //重新生成新的数字
            generateRandomNumber()
            
        }
    }
    
    /*
        作者:张振东
        时间:2016-9-22
        功能:监听键盘即将隐藏时的事件
     */
//    func handleKeyboardWillHide(notification:NSNotification){
//        if ((finishBtn?.superview) != nil){
//            finishBtn?.removeFromSuperview()
//        }
//    }

    
    /*
     作者:张振东
     时间:2016-9-11
     功能:封装UIlabel对象的属性®
     */
    @discardableResult
    func fengZhuangLabelAttributes(_ label:UILabel) -> UILabel{
        label.font = UIFont.systemFont(ofSize: 12)
        label.textAlignment = .center
        
        switch label {
        case zhengQueShuLabel!:
            label.text = "正确数"
        case zhengQueShuLabelValue!:
            label.text = "\(zhengQueShu)"
        case zhengQueLvLabel!:
            label.text = "正确率"
        case zhengQueLvLabelValue!:
            label.text = "0%"
        case shiJianLabel!:
            label.text = "时间"
        case shiJianLabelValue!:
            label.text = "00:00:00"
        case suDuLabel!:
            label.text = "速度"
        case suDuLabelValue!:
            label.text = "0字/分钟"
            
        default: break
            
        }
        return label
    }

    /*
        作者:张振东
        时间:2016-9-11
        功能:实现跳转至设置界面的ViewController功能
     */
    func tiaoZhuanDaoSheZhiViewController(){
        timer.invalidate()
        print(timerValue)
        let sheZhiLabelYangShiViewController = SheZhiLabelYangShiViewController()
        sheZhiLabelYangShiViewController.delegate = self
        UserDefaults.standard.set(timerValue, forKey: "timerValue")
        
        
        //将传递过来的分钟值传递到下一个ViewController
        sheZhiLabelYangShiViewController.xuanZhongDeFenZhongValue = fenZhongZhi
        print(sheZhiLabelYangShiViewController.xuanZhongDeFenZhongValue as Any)
        self.navigationController?.pushViewController(sheZhiLabelYangShiViewController, animated: true)
    }
    
    /*
     作者:张振东
     时间:2016-9-15
     功能:设置结束之后在原来的基础上进行计时
     */
    func chuanDiFenZhongZhiDaoXiaoJianPan(_ fenZhongZhi: Int) {
       
        timerValue = fenZhongZhi
        if timer != nil{
            timer.invalidate()
            timer = nil
        }
        timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
        
        
    }
    
    func chuanDiXuanZhongFenZhongZhiDaoXiaoJianPan(_ xuanZhongDeFenZhongValueJieBao: Int) {
        print(xuanZhongDeFenZhongValueJieBao)
        fenZhongZhi = String(xuanZhongDeFenZhongValueJieBao)
        print(fenZhongZhi as Any)
    }
//    
//    func chuanDiFenZhongZhiDaoXiaoJianPan(fenZhongZhi: Int, xuanZhongFenZhongValue: Int) {
//        timerValue = fenZhongZhi
//        print(xuanZhongFenZhongValue)
//        timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
//    }
    
    /*
        作者:张振东
        时间:2016-9-11
        功能:封装6个存储随机生成的数字的Label对象
     */
    func fengZhuangSixUiLabelAttributes(_ label:UILabel){
        label.layer.borderWidth = 1
        label.layer.borderColor = UIColor.orange.cgColor
        label.textAlignment = .center
        label.layer.cornerRadius = 20
        label.font = UIFont.systemFont(ofSize: 15)
    }
    
    /*
        作者:张振东
        时间:2016-9-11
        功能:封装6个UITextField对象
     */
    func fengZhuangSixUiTextFieldAttributes(_ textField:UITextField){
        textField.layer.borderWidth = 1
        textField.layer.borderColor = UIColor.orange.cgColor
        textField.textAlignment = .center
        textField.layer.cornerRadius = 20
        textField.font = UIFont.systemFont(ofSize: 15)
        textField.keyboardType = .numberPad
        textField.isUserInteractionEnabled = false
        textField.delegate = self
        
        switch textField {
        case firstTextFieldValue!:
            textField.tag = 0
            break
        case secondTextFieldValue!:
            textField.tag = 1
            break

        case thirdTextFieldValue!:
            textField.tag = 2
            break

        case fourthTextFieldValue!:
            textField.tag = 3
            break

        case fifthTextFieldValue!:
            textField.tag = 4
            break

        case sixthTextFieldValue!:
            textField.tag = 5
            break

        default:
            print("--")
        }
    }
    
    
    func textViewDidChange(_ textView: UITextView) {
        print(textView.text)
    }
    
    /*
     作者:张振东
     日期:2016-8-11
     功能:动态计算输入的正确的数字的个数
     */
    func passwordView(_ passwordView: ZSDSetPasswordView!, inputPassword password: String!) {
        
        dianJiWanChengShuZiChuan = password
        print(password)
        suoYouZhengShu += 1
        
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        if password.characters.count % 6 == 1{
            firstTextFieldValue?.text = (password! as NSString).substring(with: NSMakeRange(password!.characters.count-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }

                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
            
        }else if password.characters.count % 6 == 2{
            secondTextFieldValue?.text = (password! as NSString).substring(with: NSMakeRange(password!.characters.count-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
            
        }else if password.characters.count % 6 == 3{
            thirdTextFieldValue?.text = (password! as NSString).substring(with: NSMakeRange(password!.characters.count-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
            
        }else if password!.characters.count % 6 == 4{
            fourthTextFieldValue?.text = (password! as NSString).substring(with: NSMakeRange(password!.characters.count-1, 1))
            
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if password!.characters.count % 6 == 5{
            fifthTextFieldValue?.text = (password! as NSString).substring(with: NSMakeRange(password!.characters.count-1, 1))
            
            
            if let fifthTextFieldInputValue = fifthTextFieldValue?.text{
                print(fifthTextFieldInputValue)
                if let fifthLabelValue = fifthLabel?.text{
                    print(fifthLabelValue)
                    if fifthTextFieldInputValue == fifthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        fifthTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if password!.characters.count % 6 == 0{
            sixthTextFieldValue?.text = (password! as NSString).substring(with: NSMakeRange(password.characters.count-1, 1))
            
            if let sixthTextFieldInputValue = sixthTextFieldValue?.text{
                print(sixthTextFieldInputValue)
                if let sixthLabelValue = sixthLabel?.text{
                    print(sixthLabelValue)
                    if sixthTextFieldInputValue == sixthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        sixthTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
            
            jianPanTextView?.becomeFirstResponder()
            jianPanTextView?.keyboardType = .numberPad
        }
        
    }
    

    
    /*
        作者:张振东
        日期:2016-9-11
        功能:用变量存储随机生成的0-9之间的数字
     */
    func jiSuanZhengQueLv() -> Double{
        
        zhengQueLv = (Double(zhengQueShu)/Double(suoYouZhengShu))*100
        //保留小数点后两位
        let zhengQueLvZhi = String(format: "%.2f", zhengQueLv)
        print(zhengQueLvZhi)
        return Double(zhengQueLvZhi)!
    }
    
    /*
     作者:张振东
     日期:2016-9-11
     功能:计算小键盘练习速度
     */
    func jiSuanLianXiSuDu() -> Int{
        print(Int(suoYouZhengShu))
        print(Int(fenZhongZhi!)!)
        let lianXiSudu = Int(suoYouZhengShu)/Int(fenZhongZhi!)!
        print(lianXiSudu)
        return lianXiSudu
    }
    
    /*
        作者:张振东
        日期:2016-9-11
        功能:用变量存储随机生成的0-9之间的数字
     */
    func generateRandomNumber(){
        for index in 0...5 {
            if index == 0{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    firstLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 1{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    secondLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 2{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    thirdLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 3{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    fourthLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 4{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    fifthLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 5{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    sixthLabel?.text = "\(randomNumber)"
                }
                
            }
        }
    }

    /*
     作者:张振东
     日期:2016-8-11
     功能:封装ViewDidLoad()
     */
    func fengZhuangViewDidLoad(){
        let leftBarButton = UIButton(frame:CGRect(x: 0,y: 0,width: 20,height: 20))
        leftBarButton.setBackgroundImage(UIImage(named: "fanhui"), for: UIControlState())
        leftBarButton.addTarget(self, action: #selector(backToPrevious), for: .touchUpInside)
        let leftBarButtonItem = UIBarButtonItem(customView: leftBarButton)
        self.navigationItem.leftBarButtonItems = [leftBarButtonItem]
        
        //设置viewController上面的标题
        if let moShiLeiBie = moShiLeiBie{
            self.title = "\(moShiLeiBie)模式"
            self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
            //修改导航栏按钮颜色
            self.navigationController?.navigationBar.tintColor = UIColor.white
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha: 1)
        }
        
        //初始化右侧的按钮
        sheZhiBtn = UIButton(frame:CGRect(x: 0, y: 0, width: 60, height: 30))
        sheZhiBtn?.setTitle("设置", for: UIControlState())
        sheZhiBtn?.setTitleColor(UIColor.white, for: UIControlState())
        sheZhiBtn!.addTarget(self,action:#selector(tiaoZhuanDaoSheZhiViewController),for:.touchUpInside)
        let rightBarButtonItem = UIBarButtonItem(customView: sheZhiBtn!)
        self.navigationItem.rightBarButtonItem = rightBarButtonItem
        
        
        //初始化scrollView
        scrollView = UIScrollView(frame:CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight))
        scrollView?.backgroundColor = UIColor.white
        scrollView?.contentSize = CGSize(width: screenWidth, height: screenHeight*2)
        scrollView?.indicatorStyle = UIScrollViewIndicatorStyle.white
        scrollView?.showsVerticalScrollIndicator = true
        scrollView?.showsHorizontalScrollIndicator = false
        
        //初始化三个imageView
        zanTingImageView = UIImageView(frame:CGRect(x:(screenWidth/3-30)/2,y:5,width:30,height:30))
        zanTingImageView!.contentMode = .scaleAspectFit
        let zanTingImage = UIImage(named: "zanting")
        zanTingImageView!.image = zanTingImage
        
        
        chaKanJieGuoImageView = UIImageView(frame:CGRect(x:(screenWidth/3)+(screenWidth/3-30)/2,y:5,width:30,height:30))
        chaKanJieGuoImageView!.contentMode = .scaleAspectFit
        let chaKanChengJiImage = UIImage(named: "chakanchengji")
        chaKanJieGuoImageView!.image = chaKanChengJiImage
        
        jieShuImageView = UIImageView(frame:CGRect(x:(screenWidth/3)*2+(screenWidth/3-30)/2,y:5,width:30,height:30))
        jieShuImageView!.contentMode = .scaleAspectFit
        let jieShuImage = UIImage(named: "jieshu")
        jieShuImageView!.image = jieShuImage
        
        
        //初始化两个View对象
        firstFenGeXianView = UIView(frame:CGRect(x:screenWidth/3,y:3,width:1,height:60))
        firstFenGeXianView!.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        secondFenGeXianView = UIView(frame:CGRect(x:(screenWidth/3)*2,y:3,width:1,height:60))
        secondFenGeXianView!.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化三个按钮
        zanTingBtn = UIButton(frame:CGRect(x: (screenWidth/3-80)/2,y: 5+30+5,width: 80,height: 20))
        
        zanTingBtn?.setTitle("暂停", for: UIControlState())
        zanTingBtn?.setTitleColor(UIColor.black, for: UIControlState())
        zanTingBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        
        chaKanJieGuoBtn = UIButton(frame:CGRect(x: (screenWidth/3)+(screenWidth/3-80)/2,y: 5+30+5,width: 80,height: 20))
        
        chaKanJieGuoBtn?.setTitle("查看结果", for: UIControlState())
        chaKanJieGuoBtn?.setTitleColor(UIColor.black, for: UIControlState())
        chaKanJieGuoBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        chaKanJieGuoBtn?.isUserInteractionEnabled = false
        
        jieShuBtn = UIButton(frame:CGRect(x: (screenWidth/3)*2+(screenWidth/3-80)/2,y: 5+30+5,width: 80,height: 20))
       
        jieShuBtn?.setTitle("结束", for: UIControlState())
       
        jieShuBtn?.setTitleColor(UIColor.black, for: UIControlState())
        jieShuBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        
        //初始化横线UIView
        hengXianView = UIView(frame:CGRect(x: 10,y: 67,width: screenWidth-10,height: 1))
        hengXianView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化8个UIlabel对象
        //初始化第一个UIlabel对象
        zhengQueShuLabel = UILabel(frame:CGRect(x: (screenWidth/4-60)/2,y: 70,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueShuLabel!)
        
        
        //初始化第二个UIlabel对象
        zhengQueShuLabelValue = UILabel(frame:CGRect(x: (screenWidth/4-60)/2,y: 70+20+5,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueShuLabelValue!)
        
        //初始化第三个UILabel对象
        zhengQueLvLabel = UILabel(frame:CGRect(x: screenWidth/4+(screenWidth/4-60)/2,y: 70,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueLvLabel!)
        
        //初始化第四个UILabel对象
        zhengQueLvLabelValue = UILabel(frame:CGRect(x: screenWidth/4+(screenWidth/4-60)/2,y: 70+20+5,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueLvLabelValue!)
        
        //初始化第五个UIlabel对象
        shiJianLabel = UILabel(frame:CGRect(x: screenWidth/2+(screenWidth/4-60)/2,y: 70,width: 60,height: 20))
        fengZhuangLabelAttributes(shiJianLabel!)
        
        //初始化第六个UIlabel对象
        shiJianLabelValue = UILabel(frame:CGRect(x: screenWidth/2+(screenWidth/4-60)/2,y: 70+20+5,width: 60,height: 20))
        fengZhuangLabelAttributes(shiJianLabelValue!)
        
        //初始化第七个UIlabel对象
        suDuLabel = UILabel(frame:CGRect(x: (screenWidth/4)*3+(screenWidth/4-60)/2,y: 70,width: 60,height: 20))
        fengZhuangLabelAttributes(suDuLabel!)
        
        //初始化第八个UIlabel对象
        suDuLabelValue = UILabel(frame:CGRect(x: (screenWidth/4)*3+(screenWidth/4-60)/2,y: 70+20+5,width: 60,height: 20))
        fengZhuangLabelAttributes(suDuLabelValue!)
        
        //初始化leftView
        leftView = UIView(frame:CGRect(x:screenWidth/4,y:70,width:1,height:50))
        leftView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化middleView
        middleView = UIView(frame:CGRect(x: screenWidth/2,y:70,width:1,height:50))
        middleView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化rightView
        rightView = UIView(frame:CGRect(x: (screenWidth/4)*3,y:70,width:1,height:50))
        rightView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化第二条横线View
        secondHengXianView = UIView(frame:CGRect(x: 10,y: 70+50+2,width: screenWidth-10,height: 1))
        secondHengXianView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化6个label对象
        firstLabel = UILabel(frame:CGRect(x: (screenWidth-240)/7,y: 80+50+10,width: 40,height: 40))
        fengZhuangSixUiLabelAttributes(firstLabel!)
        
        secondLabel = UILabel(frame:CGRect(x: ((screenWidth-240)/7)*2+40*1,y: 80+50+10,width: 40,height: 40))
        fengZhuangSixUiLabelAttributes(secondLabel!)
        
        thirdLabel = UILabel(frame:CGRect(x: ((screenWidth-240)/7)*3+40*2,y: 80+50+10,width: 40,height: 40))
        fengZhuangSixUiLabelAttributes(thirdLabel!)
        
        fourthLabel = UILabel(frame:CGRect(x: ((screenWidth-240)/7)*4+40*3,y: 80+50+10,width: 40,height: 40))
        fengZhuangSixUiLabelAttributes(fourthLabel!)
        
        fifthLabel = UILabel(frame:CGRect(x: ((screenWidth-240)/7)*5+40*4,y: 80+50+10,width: 40,height: 40))
        fengZhuangSixUiLabelAttributes(fifthLabel!)
        
        sixthLabel = UILabel(frame:CGRect(x: ((screenWidth-240)/7)*6+40*5,y: 80+50+10,width: 40,height: 40))
        fengZhuangSixUiLabelAttributes(sixthLabel!)
        
        //支付宝支付密码
        inputViews = ZSDSetPasswordView(frame:CGRect(x: (screenWidth-240)/7,y: 80+50+10+40+10,width: screenWidth-2*(screenWidth-240)/7,height: 40))
        inputViews?.layer.borderWidth = 0
//        inputViews?.layer.borderColor = UIColor.redColor().CGColor
        inputViews?.delegate = self
        
    
        //初始化6个UITextField对象
        firstTextFieldValue = UITextField(frame:CGRect(x: 0,y: 0,width: 40,height: 40))
        fengZhuangSixUiTextFieldAttributes(firstTextFieldValue!)
        
        secondTextFieldValue = UITextField(frame:CGRect(x: (screenWidth-240)/7+40*1,y: 0,width: 40,height: 40))
        fengZhuangSixUiTextFieldAttributes(secondTextFieldValue!)
        
        thirdTextFieldValue = UITextField(frame:CGRect(x: ((screenWidth-240)/7)*2+40*2,y: 0,width: 40,height: 40))
        fengZhuangSixUiTextFieldAttributes(thirdTextFieldValue!)
        
        fourthTextFieldValue = UITextField(frame:CGRect(x: ((screenWidth-240)/7)*3+40*3,y: 0,width: 40,height: 40))
        fengZhuangSixUiTextFieldAttributes(fourthTextFieldValue!)
        
        fifthTextFieldValue = UITextField(frame:CGRect(x: ((screenWidth-240)/7)*4+40*4,y: 0,width: 40,height: 40))
        fengZhuangSixUiTextFieldAttributes(fifthTextFieldValue!)
        
        sixthTextFieldValue = UITextField(frame:CGRect(x: ((screenWidth-240)/7)*5+40*5,y: 0,width: 40,height: 40))
        fengZhuangSixUiTextFieldAttributes(sixthTextFieldValue!)
        
        //初始化键盘TextView
        jianPanTextView = UITextView(frame:CGRect(x: 0,y: screenHeight-120,width: screenWidth,height: 0))
        jianPanTextView?.delegate = self
        jianPanTextView?.becomeFirstResponder()
        jianPanTextView?.keyboardType = .numberPad
        
        //inputView获得焦点
        inputViews?.becomeFirstResponder()
    
        scrollView?.addSubview(zanTingImageView!)
        scrollView?.addSubview(chaKanJieGuoImageView!)
        scrollView?.addSubview(jieShuImageView!)
        scrollView?.addSubview(firstFenGeXianView!)
        scrollView?.addSubview(secondFenGeXianView!)
        scrollView?.addSubview(zanTingBtn!)
        scrollView?.addSubview(chaKanJieGuoBtn!)
        scrollView?.addSubview(jieShuBtn!)
        scrollView?.addSubview(hengXianView!)
        scrollView?.addSubview(zhengQueShuLabel!)
        scrollView?.addSubview(zhengQueLvLabel!)
        scrollView?.addSubview(shiJianLabel!)
        scrollView?.addSubview(suDuLabel!)
        scrollView?.addSubview(zhengQueShuLabelValue!)
        scrollView?.addSubview(zhengQueLvLabelValue!)
        scrollView?.addSubview(shiJianLabelValue!)
        scrollView?.addSubview(suDuLabelValue!)
        scrollView?.addSubview(leftView!)
        scrollView?.addSubview(middleView!)
        scrollView?.addSubview(rightView!)
        scrollView?.addSubview(secondHengXianView!)
        scrollView?.addSubview(firstLabel!)
        scrollView?.addSubview(secondLabel!)
        scrollView?.addSubview(thirdLabel!)
        scrollView?.addSubview(fourthLabel!)
        scrollView?.addSubview(fifthLabel!)
        scrollView?.addSubview(sixthLabel!)
        scrollView?.addSubview(jianPanTextView!)
        inputViews?.addSubview(firstTextFieldValue!)
        inputViews?.addSubview(secondTextFieldValue!)
        inputViews?.addSubview(thirdTextFieldValue!)
        inputViews?.addSubview(fourthTextFieldValue!)
        inputViews?.addSubview(fifthTextFieldValue!)
        inputViews?.addSubview(sixthTextFieldValue!)
        scrollView?.addSubview(inputViews!)

        generateRandomNumber()
        self.view.addSubview(scrollView!)
        
        //分别给三个按钮添加点击事件
        zanTingBtn!.addTarget(self,action:#selector(zanTing),for:.touchUpInside)
        chaKanJieGuoBtn!.addTarget(self,action:#selector(chaKanJieGuo),for:.touchUpInside)
        jieShuBtn!.addTarget(self,action:#selector(jieShu),for:.touchUpInside)
        
        print(fenZhongZhi as Any)
        
        if let moShiCategory = moShiLeiBie{
            print(moShiCategory)
            if moShiCategory == "计时"{
                timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
            }else if moShiCategory == "定时"{
                //将传递过来的分钟值转换为秒数
                timerValue = 60 * Int(fenZhongZhi!)!
                
                timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuXuanZhongFenZhongZhiDaoJiShi), userInfo: nil, repeats: true)
            }
        }
        super.viewDidLoad()
    
    }
    
    /*
        作者:张振东
        日期:2016-09-06
        功能:显示计时时间
     */
    func genJuSelectedValueJiShi(){
        timerValue += 1
        print(fenZhongZhi as Any)
    
        //获得分钟
        let fenZhongValue = timerValue/60
        //获取秒数
        let miaoValue = timerValue%60
        
        if fenZhongValue < 10 {
            if miaoValue < 10 {
                shiJianLabelValue?.text = "00:0\(fenZhongValue):0\(miaoValue)"
            }else{
                shiJianLabelValue?.text = "00:0\(fenZhongValue):\(miaoValue)"
            }
        }else{
            if miaoValue < 10{
                shiJianLabelValue?.text = "00:\(fenZhongValue):0\(miaoValue)"
            }else{
                shiJianLabelValue?.text = "00:\(fenZhongValue):\(miaoValue)"
            }
        }
        
        //当计时结束时,可以在此进行if语句中显示最终的结果
        if timerValue == Int(fenZhongZhi!)! * 60{
            timer.invalidate()
            inputViews?.isUserInteractionEnabled = false
            
            //当传递过来的时间消耗完毕,计时就要从0开始
            timerValue = 0
//          zhengQueShu = 0
//          zhengQueLv = 0
//          xiaoJianPanLianXiSuDu = 0
            print("倒计时结束")
        }
        
        print(timerValue)
    }

    /*
        作者:张振东
        日期:2016-09-06
        功能:显示计时时间
     */
    func genJuXuanZhongFenZhongZhiDaoJiShi(){
        print(fenZhongZhi!)
        print(timerValue)
        timerValue = timerValue - 1
        //获得分钟
        let minuteValue = timerValue/60
        //获得秒数
        let secondsValue = timerValue%60
        if minuteValue < 10{
            if secondsValue < 10{
                shiJianLabelValue?.text = "00:0\(minuteValue):0\(secondsValue)"
            }else{
                shiJianLabelValue?.text = "00:0\(minuteValue):\(secondsValue)"
            }
        }else{
            if secondsValue < 10{
                shiJianLabelValue?.text = "00:\(minuteValue):0\(secondsValue)"
            }else{
                shiJianLabelValue?.text = "00:\(minuteValue):\(secondsValue)"
            }
        }
        //当计时结束时,可以在此进行if语句中显示最终的结果
        if timerValue == 0{
            //表示倒计时结束
            timer.invalidate()
            inputViews?.isUserInteractionEnabled = false
            timerValue = 0
            print("倒计时结束!!")
        }
        
    }
    
    
    
    /*
        作者:张振东
        日期:2016-09-11
        功能:当用户点击暂停时所作的操作
            1、所有的textFieldValue失去交互性
            2、将上面的正确数、正确率、时间、速度保存在本地
            3、暂停两个字修改为开始
            4、让时间失去交互性
     */
    func zanTing(){
        print("暂停按钮被点击")
        //点击暂停之后,查看结果的按钮才具有交互性
        chaKanJieGuoBtn?.isUserInteractionEnabled = true
        
        zanTingBtn?.isSelected = !(zanTingBtn?.isSelected)!
        print(zanTingBtn?.isSelected as Any)
        if zanTingBtn?.isSelected == true{
            //1、所有的textFieldValue失去交互性
            firstTextFieldValue?.isUserInteractionEnabled = false
            secondTextFieldValue?.isUserInteractionEnabled = false
            thirdTextFieldValue?.isUserInteractionEnabled = false
            fourthTextFieldValue?.isUserInteractionEnabled = false
            fifthTextFieldValue?.isUserInteractionEnabled = false
            sixthTextFieldValue?.isUserInteractionEnabled = false
            inputViews?.isUserInteractionEnabled = false
            jianPanTextView?.isUserInteractionEnabled = false
            
            //2、将上面的正确数、正确率、时间、速度保存在本地
            UserDefaults.standard.set(zhengQueShu, forKey: "zhengQueShuInt")
            UserDefaults.standard.set(zhengQueLv, forKey: "zhengQueLv")
            UserDefaults.standard.set(timerValue, forKey: "timerValue")
            UserDefaults.standard.set(xiaoJianPanLianXiSuDu, forKey: "xiaoJianPanLianXiSuDu")
            
            let a = UserDefaults.standard.integer(forKey: "timerValue")
            print(a)
            
            UserDefaults.standard.synchronize()
            
            //暂停两个字修改为开始
            zanTingBtn?.setTitle("开始", for: UIControlState())
            //暂停的按钮修改为开始按钮
            let kaiShiImage = UIImage(named: "begin")
            zanTingImageView!.image = kaiShiImage
            zanTingBtn?.setTitleColor(UIColor.gray, for: UIControlState())
            //让时间失去交互性
            timer.invalidate()
        }else{
            inputViews?.isUserInteractionEnabled = true
            jianPanTextView?.isUserInteractionEnabled = true
            //让暂停恢复原状
            zanTingBtn?.setTitle("暂停", for: UIControlState())
            let zanTingImage = UIImage(named: "zanting")
            zanTingImageView!.image = zanTingImage
            zanTingBtn?.setTitleColor(UIColor.black, for: UIControlState())
            
            //当开始的时候,查看结果按钮是不具有交互性的
            chaKanJieGuoBtn?.isUserInteractionEnabled = false
            
            if let moShiCategory = moShiLeiBie{
                print(moShiCategory)
                if moShiCategory == "计时"{
                    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
                }else if moShiCategory == "定时"{
                     timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuXuanZhongFenZhongZhiDaoJiShi), userInfo: nil, repeats: true)
                }
            }
        }
    }
    
    /*
        作者:张振东
        日期:2016-09-06
        功能:跳转至另一个界面,显示训练结果
            1、跳转至查看结果的界面
            2、将值传递过去
     */
    func chaKanJieGuo(){
        let chaKanJieGuoViewController = ChaKanJieGuoViewController()
        if let moShiCategory = moShiLeiBie{
            print(moShiCategory)
            chaKanJieGuoViewController.moShiCategory = moShiCategory
            chaKanJieGuoViewController.miniteValue = Int(fenZhongZhi!)!
        }
        self.navigationController?.pushViewController(chaKanJieGuoViewController, animated: true)
    }
    
    /*
        作者:张振东
        日期:2016-09-06
        功能:训练结束
            1、时间失效
            2、6个textFieldValue失效
     */
    func jieShu(){
        //1、时间失效
        timer.invalidate()
        
        //2、6个textFieldValue失效
        firstTextFieldValue?.isUserInteractionEnabled = false
        secondTextFieldValue?.isUserInteractionEnabled = false
        thirdTextFieldValue?.isUserInteractionEnabled = false
        fourthTextFieldValue?.isUserInteractionEnabled = false
        fifthTextFieldValue?.isUserInteractionEnabled = false
        sixthTextFieldValue?.isUserInteractionEnabled = false
        
        //将值保存下来:经测试,保存成功
        UserDefaults.standard.set(zhengQueShu, forKey: "zhengQueShuInt")
        UserDefaults.standard.set(zhengQueLv, forKey: "zhengQueLv")
        UserDefaults.standard.set(timerValue, forKey: "timerValue")
        UserDefaults.standard.set(xiaoJianPanLianXiSuDu, forKey: "xiaoJianPanLianXiSuDu")
    }
    
    //获得传递过来的暂停按钮的状态
    func chuanDiZanTingOrkaiShiStatus(_ zanTingOrKaiShiStatus: Bool) {
        //表示暂停状态,这是计时器不走
        if zanTingOrKaiShiStatus == true{
            if timer != nil{
                timer.invalidate()
                timer = nil
            }
        }else{
            //表示为开始状态
            if timer != nil{
                timer.invalidate()
                timer = nil
            }
            if let moShiCategory = moShiLeiBie{
                print(moShiCategory)
                if moShiCategory == "计时"{
                    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
                }else if moShiCategory == "定时"{
                    //将传递过来的分钟值转换为秒数
                    timerValue = 60 * Int(fenZhongZhi!)!
                    
                    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuXuanZhongFenZhongZhiDaoJiShi), userInfo: nil, repeats: true)
                }
            }
            
            
        }
    }

    
    /*
        作者:张振东
        日期:2016-09-17
        功能:接收传递过来的indexPathDianRow
    */
    func chuanDiIndexPathDianRow(_ indexPathDianRow: Int) {
        self.indexPathDianRow = indexPathDianRow
        switch indexPathDianRow {
        case 0:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            break
        case 1:
            
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor

            break
        case 2:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor

            break
        case 3:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor

            break

        case 4:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor

            break
        case 5:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor

            break

        case 6:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor

            break
        case 7:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor

            break

        case 8:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor

            break
        case 9:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor

            break

        case 10:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor

            break
        case 11:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor

            break

        case 12:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor

            break
        case 13:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor

            break

        case 14:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor

            break
        case 15:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            fifthLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            sixthLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            fifthTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            sixthTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor

            break

        case 16:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
            break
        default:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
        }
    }
    
    func chuanDiXuanZhongFenZhongValueAndBianKuangXingZhuang(_ xuanZhongFenZhongValue: Int, indexPathDianRow: Int) {
        print(xuanZhongFenZhongValue)
        print(indexPathDianRow)
        bianKuangXingZhuangIndexPathDianRow = indexPathDianRow
        switch bianKuangXingZhuangIndexPathDianRow {
        case 0:
            //将UILabel和UItextField的边框修改为正方形
            firstLabel?.layer.cornerRadius = 0
            secondLabel?.layer.cornerRadius = 0
            thirdLabel?.layer.cornerRadius = 0
            fourthLabel?.layer.cornerRadius = 0
            fifthLabel?.layer.cornerRadius = 0
            sixthLabel?.layer.cornerRadius = 0
            
            firstTextFieldValue?.layer.cornerRadius = 0
            secondTextFieldValue?.layer.cornerRadius = 0
            thirdTextFieldValue?.layer.cornerRadius = 0
            fourthTextFieldValue?.layer.cornerRadius = 0
            fifthTextFieldValue?.layer.cornerRadius = 0
            sixthTextFieldValue?.layer.cornerRadius = 0
            
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
            break
        case 1:
            //将UILabel和UItextField的边框修改为正方形
            firstLabel?.layer.cornerRadius = 20
            secondLabel?.layer.cornerRadius = 20
            thirdLabel?.layer.cornerRadius = 20
            fourthLabel?.layer.cornerRadius = 20
            fifthLabel?.layer.cornerRadius = 20
            sixthLabel?.layer.cornerRadius = 20
            
            firstTextFieldValue?.layer.cornerRadius = 20
            secondTextFieldValue?.layer.cornerRadius = 20
            thirdTextFieldValue?.layer.cornerRadius = 20
            fourthTextFieldValue?.layer.cornerRadius = 20
            fifthTextFieldValue?.layer.cornerRadius = 20
            sixthTextFieldValue?.layer.cornerRadius = 20
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
            break
        default:
            print("default")
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
        }
    }
    
    
    //返回至上一个界面
    func backToPrevious(){
        self.navigationController?.popViewController(animated: true)
    }

    override func viewDidAppear(_ animated: Bool) {
        print(self.view.subviews)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
